package {
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	
	import com.bumpslide.ui.Applet;
	import com.bumpslide.ui.Image;		

	/**
	 * @author David Knape
	 * @mxmlc -sp+=../../classes
	 */
	public class URLLoaderImage extends Applet {

		static private const SAMPLE_IMAGE_URL:String="http://farm4.static.flickr.com/3120/2743968785_3e0869bf42.jpg";
		private var loader:URLLoader;

		public function URLLoaderImage() {
			loader = new URLLoader(new URLRequest(SAMPLE_IMAGE_URL));
			loader.dataFormat = URLLoaderDataFormat.BINARY;
			loader.addEventListener(Event.COMPLETE, onDataLoaded);
		}

		private function onDataLoaded(e:Event):void {
			var img:Image=new Image();
			img.loadBytes(loader.data);
			addChild(img);
		}
	}
}